import {getUrl,postUrl} from '@/utils/http/htpp'

//医药商品接口
export const drugShop=()=>{
    return getUrl('https://api-hmugo-web.itheima.net/api/public/v1/categories')
}

//更新头像
export const updateImg = (data) => {
    const param = new FormData()
    data.forEach((img, index) => {
        param.append(img.name + index, img, img.name);
    });
    return postUrl('/v1/image/upload', param)
}

//获取头像
export const getImageUrl = (imageKey, sex, baseURL) => {
    if (!imageKey && sex !== undefined) {
        return require(`../../public/uugai.com_1608208165258.png-${sex || '0'}.jpg`);
    }
    /* eslint-disable */
    try {
        return `${baseURL || 'http://47.101.45.245:8878'}/v1/image/${imageKey}`;
    } catch (error) {
        throw error;
    }
    /* eslint-disable */
}